package work.parabola.keyboardswitch.pojo.query.keyswitch;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;
import work.parabola.keyboardswitch.common.ServerResponse;

@Data
@ToString
@EqualsAndHashCode
public class ListQuery {

    private int pageNum = 1;

    private int pageSize = 10;

    private String keyword;

    private Boolean onlyShowNoColor;

    private Boolean onlyShowNoManufacturer;

    public ServerResponse validate() {
        if (StringUtils.isBlank(this.keyword)) {
            this.keyword = null;
        } else {
            this.keyword = "%" + this.keyword + "%";
        }
        if (this.onlyShowNoColor == null) {
            this.onlyShowNoColor = false;
        }
        if (this.onlyShowNoManufacturer == null) {
            this.onlyShowNoManufacturer = false;
        }
        return ServerResponse.createBySuccess();
    }
}
